<?php /* Smarty version 2.6.18, created on 2010-03-16 09:24:54
         compiled from selectreason.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'cycle', 'selectreason.tpl', 15, false),)), $this); ?>

<input type="hidden" name="id" value="<?php echo $this->_tpl_vars['id']; ?>
">
<table class="popup" border="0" cellspacing=0 cellpadding=0 width="100%">
	<tr><td><div class="pop"><div class="top_pop"><img src="/app/default/www/images/top_left_pop.jpg" /></div> 
		<div id="drag_bar"><h2 class="pop_h2">&nbsp;&nbsp;Reject Reason</h2></div>
		<div class="content">
			<table border="0" width="100%">
				<tr>
					<td>Qty</td>
					<td>Reason</td>
				</tr>
				<tr><td colspan="2"><hr></td></tr>
			<?php $_from = $this->_tpl_vars['reasonList']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
				<?php $this->assign('key', $this->_tpl_vars['list']['reject_reason_id']); ?>
				<tr class="<?php echo smarty_function_cycle(array('values' => 'blue,notify'), $this);?>
">
					<td width="10%"><input style="width:30px;" type="text" name="reason[<?php echo $this->_tpl_vars['list']['reject_reason_id']; ?>
]" value="<?php echo $this->_tpl_vars['items'][$this->_tpl_vars['key']]; ?>
" id="reason[<?php echo $this->_tpl_vars['list']['reject_reason_id']; ?>
]" ></td>
					<td><?php echo $this->_tpl_vars['list']['reason']; ?>
</td>
				</tr>
			<?php endforeach; endif; unset($_from); ?>
				<tr><td colspan="2"><hr></td></tr>
				<tr>
					<td colspan="2" align="center">
						<input type="button" value="Save" onclick="save();" >
						<input type="button" value="Close" onclick="popup('reason');">		
					</td>
				</tr>
			</table>
		</div>
		<div class="btm_pop"><img src="/app/default/www/images/btm_left_pop.jpg"  alt="" />
	</td></tr>		
</table>

<script language="javascript">
<?php echo '
	function save(){
		var tqty = 0;
'; ?>

		<?php $_from = $this->_tpl_vars['reasonList']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
			if(document.getElementById('reason['+  <?php echo $this->_tpl_vars['list']['reject_reason_id']; ?>
  + ']').value > 0 ) {
				rqty = parseInt(document.getElementById('reason['+ <?php echo $this->_tpl_vars['list']['reject_reason_id']; ?>
 + ']').value);
				tqty = parseInt(tqty+rqty);
			}
			
		<?php endforeach; endif; unset($_from); ?>
<?php echo '
		
		if( '; ?>
 <?php echo $this->_tpl_vars['qty']; ?>
 <?php echo ' == tqty ) {
			document.getElementById(\'reasonqty[\'+ '; ?>
 <?php echo $this->_tpl_vars['id']; ?>
 <?php echo ' + \']\').value = tqty;
			doajaxAction(\'/account/saveReason/\',1,\'reason\',document.getElementById(\'mainForm\'),true);
			popup(\'reason\');
		} else {
			alert(\'Qty is not equal to reject qty\');
		}
	}
'; ?>

</script>